<template>
  <div>
     <el-table
      :data="list"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      border
    >
      <el-table-column prop="title" label="活动名称" sortable width="180">
      </el-table-column>
      <el-table-column prop="status" label="状态" sortable>
        <template slot-scope="scope">
          <el-button disabled v-if="scope.row.status == 1" type="primary"
            >启用</el-button
          >
          <el-button disabled v-else type="info">禁用</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="name" label="操作" sortable>
        <template slot-scope="scope">
          <el-button type="primary" @click="openUpdate(scope.row.id)"
            >编辑</el-button
          >
          <el-button type="danger" @click="del(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { reqseckdelete} from "../../../http/api";
import { successAlert } from "../../../utils/alert";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapGetters({list:'seckill/list'}),
  },
  mounted() {
    this.getList();
  },
  methods: {
    ...mapActions({getList:'seckill/getList'}),
    //点击修改按钮
    openUpdate(id){
        this.$emit('showUpdate',id)
    },
    //删除
    del(id) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          let { data: res } = await reqseckdelete({ id });
          if (res.code == 200) {
            successAlert(res.msg);
            this.getList();
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "删除已取消!",
          });
        });
    },
  },
};
</script>
<style scoped lang="less">
@import "../../../less/index.less";
img{
  width: 50px;
  height: 50px;
}
</style>